#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cmath>
#include <cstring>
#include <algorithm>

using namespace std;

class Solution {
public:
    int findMaxRange(vector<int>nums, int l, int r) {
        return *max_element(nums.begin() + l, nums.begin() + r + 1);
    }
    int minMovementsToEnd(vector<int> &nums) {
        int i = 0;
        for (auto &num : nums) {
            num += (i++);
        }
        int l = 0, r = 0;
        int res = 0;
        while (r < nums.size() - 1) {
            int t = findMaxRange(nums,l,r);
            ++res;
            l = r + 1;
            r = t;
            if (l > r) return -1;
        }
        return res;
    }

};

int main() {
    string readed;
    getline(cin, readed);
    stringstream thisline(readed);
    int num;
    vector<int>nums;
    while (thisline >> num) {
        nums.push_back(num);
    }
    cout <<  Solution().minMovementsToEnd(nums) << endl;
    //system("pause");
    return 0;
}
